#!/bin/bash
# This script run at 00:00

# The Nginx logs path
logs_path="/usr/local/nginx/logs/"

mkdir -p ${logs_path}$(date -d "yesterday" +"%Y")/$(date -d "yesterday" +"%m")/
mv ${logs_path}nginx_access.log ${logs_path}$(date -d "yesterday" +"%Y")/$(date -d "yesterday" +"%m")/nginx_access_$(date -d "yesterday" +"%Y%m%d").log
ps aux | grep nginx | grep master | grep -v "grep" | awk '{print $2}' | xargs kill -USR1
echo 'cut log done.'